/**
 * @program: yygh_parent
 * @ClassName xx
 * @description:
 * @author: zyw
 * @create: 2023-05-17 14:51
 * @Version 1.0
 **/

public class xx {
    public static void main(String[] args) {
        Test mv = new Test();
        Thread t1 = new ThreadExample(mv);
        Thread t2 = new ThreadExample(mv);
        Thread t3 = new ThreadExample(mv);
        t1.start();t2.start();t3.start();
    }
}
class Test {
    private int data;
    int result = 0;
    public void m() {
        result += 2;
        data += 2;
        System.out.print(result + "  " + data);
    }
}
class ThreadExample extends Thread {
    private Test mv;
    public ThreadExample(Test mv) {this.mv = mv;}
    public void run() {synchronized (mv) {mv.m();}}
}
 
